package com.scpii.api.common.auth;

import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class ClientAuthenticationDetails implements Serializable {

	private static final long serialVersionUID = -4809832298438307309L;

	public static final String ACCESS_TOKEN_VALUE = ClientAuthenticationDetails.class
			.getSimpleName() + ".ACCESS_TOKEN_VALUE";

	private final String remoteAddress;

	private final String sessionId;

	private final String tokenValue;

	public ClientAuthenticationDetails(HttpServletRequest request) {
		this.tokenValue = (String) request.getAttribute(ACCESS_TOKEN_VALUE);
		this.remoteAddress = request.getRemoteAddr();

		HttpSession session = request.getSession(false);
		this.sessionId = (session != null) ? session.getId() : null;
	}

	public String getTokenValue() {
		return tokenValue;
	}

	public String getRemoteAddress() {
		return remoteAddress;
	}

	public String getSessionId() {
		return sessionId;
	}

}
